//
//  DSPeripheral.swift
//  DSP
//
//  Created by tucici on 2024/7/4.
//

import UIKit
import RealmSwift
import SwiftyJSON
import CoreBluetooth
class DSPeripheral: Object, NSCopying {
    var peripheral : CBPeripheral?
    @objc dynamic var name : String = "Custom Name"
    @objc dynamic var uuid : String = ""
    override class func primaryKey() -> String? {
        return "uuid"
    }
    required override init() {}
    init(peripheral:CBPeripheral){
        self.peripheral = peripheral
        self.uuid = peripheral.mac.count > 0 ? peripheral.mac : peripheral.identifier.uuidString
    }
    
    func copy(with zone: NSZone? = nil) -> Any {
        let copy = type(of: self).init()
        copy.peripheral = peripheral
        copy.name = name
        copy.uuid = uuid
        return copy
    }
    
}
